﻿<font color='black'>
<?php
include ('\lang\rus.php');
$action = "abbyss";
function getClazs($data) 
{
switch ($data) {
 case "WARRIOR": $player_class="Воин";break;
 case "GLADIATOR": $player_class="Гладиатор";break;
 case "TEMPLAR": $player_class="Страж";break;
 case "SCOUT": $player_class="Следопыт";break;
 case "ASSASSIN": $player_class="Убийцы";break;
 case "RANGER": $player_class="Стрелок";break;
 case "MAGE": $player_class="Маг";break;
 case "SORCERER": $player_class="Волщебник";break;
 case "SPIRIT_MASTER": $player_class="Заклинатель";break;
 case "PRIEST": $player_class="Прист";break;
 case "CLERIC": $player_class="Целитель";break;
 case "CHANTER": $player_class="Чантер";break;
}
}

function getPlayers() {

$q = mysql_query("SELECT player_id, daily_kill, name, exp, race, all_kill, rank FROM abyss_rank LEFT JOIN players ON player_id = id where all_kill >= 1 ORDER BY -all_kill ");


while($row = mysql_fetch_array($q))
{
$data["name"][]=$row["name"];
$data["race"][]=getRace($row["race"]);
$data["lvl"][]=getLevel($row["exp"]);
$data["legion"][]=getLegion($row["player_id"]);
$data["class"][] = getClazs($row["player_class"]);
$data["ap"][]=$row["ap"];
$data["kills"][]=$row["all_kill"];
$data["class"][] = ($row["player_class"]);
$data["dkill"][]=$row["daily_kill"];
} 
mysql_free_result($q);
return $data;
}

function getMembers($data) {
$qa=mysql_query("SELECT COUNT(*) as count FROM legion_members WHERE legion_id='".$data."'");
$row=mysql_fetch_array($qa);
$members=$row["count"];

mysql_free_result($qa);

return $members;
}

function getLeader($data) {
$qa=mysql_query("SELECT name,race FROM players WHERE id='".$data."'");
$row=mysql_fetch_array($qa);
$leader["leader"]=$row["name"];
$leader["race"]=$row["race"];
mysql_free_result($qa);

return $leader;
}

function getLegions() {
$q = mysql_query("SELECT l.id as id, l.name as name, l.level as lvl, l.contribution_points as cp, lm.player_id as leader FROM legions as l LEFT JOIN legion_members as lm ON l.id=lm.legion_id WHERE lm.rank='BRIGADE_GENERAL' ORDER BY l.contribution_points DESC LIMIT 100");
while(@$row = mysql_fetch_array($q))
{
$data["name"][]=$row["name"];
$a=getLeader($row["leader"]);
$data["race"][]=getRace($a["race"]);
$data["lvl"][]=$row["lvl"];
$data["cp"][]=$row["cp"];
$data["leader"][]=$a["leader"];
$data["members"][]=getMembers($row["id"]);
} 
@mysql_free_result($q);

return @$data;
}

?>

<p style="text-align: center;">
 <a href="index.php?action=abyss&rank=players" alt="Топ ПК" title="Топ ПК">Топ ПК</a>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 <a href="index.php?action=abyss&rank=legions" alt="Топ Легионов" title="Топ Легионов">Топ Легионов</a>

 </p><br>
 <p align="center" color="silver">В топе указаны игроки у которых 1 и более убийство.</p>

<?php 
if (isset($_REQUEST["rank"]))
{
 if ($_REQUEST["rank"]=="players") $show=1;
 elseif ($_REQUEST["rank"]=="legions") $show=0;
}
else $show=1;

if ($show==1){/* ***************** players ranking**************** */
?>
<table width='99%' border='0' cellpadding='0' cellspacing='0' bordercolor='#6b6b6b'>
 <tr align='center'>
  <td><font size='3'>#</font></td>
 <td><font size='3'><b><?php print $name;?></b></font></td>
  <td><font size='3'><b><?php print $race;?></b></font></td>
  <td><font size='3'><b><?php print $level;?></b></font></td>
  <td><font size='3'><b><?php print $legion;?></b></font></td>
  <td><font size='3'><b><?php print $PK;?></b></font></td>
<td><font size='3'><b> ПК сегодня</b></font></td>
 <td><font size='3'><b>Класс</b></font></td>
 </tr>


 
<?php 

$data=getPlayers();
for ($i=0;count($data["name"])>$i;$i++) {
?>
 <tr align='center'>
  <td  style='background:url(images/news_back.png)'>
   <font size='2' color='black'>
    <strong><?php echo ($i+1);?></strong>
   </font>
  </td>
  <td  style='background:url(images/news_back.png)'>
   <font size='2' color='black'>
    <strong><?php echo $data["name"][$i];?></strong>
   </font>
  </td>
  <td  style='background:url(images/news_back.png)'>
   <font size='2' color='black'>
    <strong><?php echo $data["race"][$i];?></strong>
   </font>
  </td>
  <td  style='background:url(images/news_back.png)'>
   <font size='2' color='black'>
    <strong><?php echo $data["lvl"][$i];?></strong>
   </font>
  </td>
<td  style='background:url(images/news_back.png)'>
   <font size='2' color='black'>
    <strong><?php echo $data["legion"][$i];?></strong>
   </font>
  </td>

  <td  style='background:url(images/news_back.png)'>
   <font size='2' color='black'>
    <strong><?php echo $data["kills"][$i];?></strong>
   </font>
  </td>
  <td  style='background:url(images/news_back.png)'>
   <font size='2' color='black'>
    <strong><?php echo $data["dkill"][$i];?></strong>
   </font>
  </td>
<td  style='background:url(images/news_back.png)'>
   <font size='2' color='black'>
    <strong><?php echo $data["class"][$i];?></strong>
   </font>
  </td>
 </tr>
<?php
}//end cyklus for
?> 
</table>
<?php
}//end of show of players ranking
else{ /* ***************** legions ranking**************** */
?>
<table width='99%' border='0' cellpadding='0' cellspacing='0' bordercolor='#6b6b6b'>
 <tr align='center'>
  <td><font size='3'><b>Место</b></font></td>
  <td><font size='3'><b>Название</b></font></td>
  <td><font size='3'><b>Раса</b></font></td>
  <td><font size='3'><b>Уровень</b></font></td>
  <td><font size='3'><b>Очки легиона</b></font></td>
  <td><font size='3'><b>Легат</b></font></td>
  <td><font size='3'><b>Участников</b></font></td>
 </tr>
 <tr>
  <td>&nbsp;</td>
 </tr>
 <?php 
$data=getLegions();
for ($i=0;count($data["name"])>$i;$i++) {
?>
 <tr align='center'>
  <td  style='background:url(images/news_back.png)'>
   <font size='2' color='black'>
    <strong><?php echo ($i+1);?></strong>
   </font>
  </td>
  <td  style='background:url(images/news_back.png)'>
   <font size='2' color='black'>
    <strong><?php echo $data["name"][$i];?></strong>
   </font>
  </td>
  <td  style='background:url(images/news_back.png)'>
   <font size='2' color='black'>
    <strong><?php echo $data["race"][$i];?></strong>
   </font>
  </td>
  <td  style='background:url(images/news_back.png)'>
   <font size='2' color='black'>
    <strong><?php echo $data["lvl"][$i];?></strong>
   </font>
  </td>
  <td  style='background:url(images/news_back.png)'>
   <font size='2' color='black'>
    <strong><?php echo $data["cp"][$i];?></strong>
   </font>
  </td>
  <td  style='background:url(images/news_back.png)'>
   <font size='2' color='black'>
    <strong><?php echo $data["leader"][$i];?></strong>
   </font>
  </td>
  <td  style='background:url(images/news_back.png)'>
   <font size='2' color='black'>
    <strong><?php echo $data["members"][$i];?></strong>
   </font>
  </td> 
 </tr>
<?php
}//end cyklus for
?> 
 </tr>
</table>
<?php
}//end of show of legions ranking
?>
 </font>